package my.study.demo.proxy.client;

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Test01 {
    public static final int a = 1;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();

        int charACount = getCount('A', s);
        int charSCount = getCount('S', s);
        int charDCount = getCount('D', s);
        int charWCount = getCount('W', s);

        int average = s.length()/4;

        int finalResult = 0;
        List<Integer> countList = Arrays.asList(charACount, charSCount, charDCount, charWCount);
        for(Integer count : countList) {
            if(count > average) {

                finalResult = finalResult + (count- average);
            }
        }
        System.out.println(finalResult);
    }

    public static int getCount(char myChar, String s) {
        int count = 0;
        int len = s.length();
        for(int i = 0; i < len; i ++){
            if(s.charAt(i) == myChar) {
                count ++;
            }
        }
        return count;
    }
}
